<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.11.0.js"></script>
    <script>
        $.ajax({
            url: "/all",
            type: "post",
            dataType: "text json",
            statusCode: {
                200: function (data) {
                    $(data).each(function () {
                        $("#show").append("<span>")
                        $("#show").append(this.id + " ")
                        $("#show").append(this.name + " ")
                        $("#show").append(this.password + " ")
                        $("#show").append("<input value='删除' type='button' onclick='delManager(" + this.id + ",\"" + this.name + "\")'></span><br>")
                    })
                }
            }
        })

        function delManager(id, name) {
            alert(id)
            alert(name)
            $.ajax({
                url: "/delete",
                type: "post",
                data: "id=" + id + "&name=" + name,
                dataType: "text",
                statusCode: {
                    200: function (data) {
                        alert(data)
                        if (data.indexOf(true) !== -1) {
                            alert("success")
                            location.reload()
                        }
                    }
                }
            })
        }
    </script>
</head>
<body>
<input type="text" id="id">
<input type="text" id="name">
<input type="text" id="password">
<input type="button" id="addManager" value="添加Manager">
<div id="show">

</div>
<script>
    $("#addManager").click(function () {
        var id = $("#id").val()
        var name = $("#name").val()
        var password = $("#password").val()
        $.ajax({
            url: "/create",
            type: "post",
            dataType: "text",
            data: "id=" + id + "&name=" + name + "&password=" + password,
            statusCode: {
                200: function (data) {
                    if (data.indexOf(true) !== -1) {
                        alert("success")
                        $("#id").val("")
                        $("#name").val("")
                        $("#password").val("")
                        location.reload()
                    }
                }
            }
        })
    })
</script>
</body>
</html>